<?php

defined( '_JEXEC' ) or die( 'Restricted access' );
/**
*	redefine pagination function;fixes JPaginations inability to define the 'base' url outside the admin panel
*		j1.5rc4+ should fix these issues &
*		make this obsolete
*/
///*
 function NewgetPagesLinks(&$pageObj, $extra){
 		//extra is a an array of key/values to append to links
		// fixes JPaginations inability to define the 'base' url outside the admin panel
        global $mainframe;
        $lang =& JFactory::getLanguage();
        $data =& $pageObj->_buildDataObject();
				
		foreach($data as $key=>$item){
			if($key == 'pages'){
				foreach($item as $page){
					if($page->link !== null ){
						foreach($extra as $k=>$v){
							if(!strstr($page->link,$k)){
								$page->link = $page->link.'&'.$k.'='.$v;
							}//end if pattern match			
						}//end foreach in extra array
					}//end if not null
				}//end pages
			}else{
				if($item->link !== null ){
						foreach($extra as $k=>$v){
							if(!strstr($item->link,$k)){
								$item->link = $item->link.'&'.$k.'='.$v;
							}//end if pattern match			
						}//end foreach in extra array
					}//end if not null
			}//end if pages
		}//end foreach in data
		
        $list = array();
        $itemOverride = false;
        $listOverride = false;
        $chromePath = JPATH_THEMES.DS.$mainframe->getTemplate().DS.'html'.DS.'pagination.php';
        if (file_exists($chromePath)){
            require_once ($chromePath);
            if (function_exists('pagination_item_active') && function_exists('pagination_item_inactive')) {
                $itemOverride = true;
            }
            if (function_exists('pagination_list_render')) {
                $listOverride = true;
            }
        }
        // Build the select list
        if ($data->all->base !== null) {
            $list['all']['active'] = true;
            $list['all']['data'] = ($itemOverride) ? pagination_item_active($data->all) : $pageObj->_item_active($data->all);
        } else {
            $list['all']['active'] = false;
            $list['all']['data'] = ($itemOverride) ? pagination_item_inactive($data->all) : $pageObj->_item_inactive($data->all);
        }
        if ($data->start->base !== null) {
            $list['start']['active'] = true;
            $list['start']['data'] = ($itemOverride) ? pagination_item_active($data->start) : $pageObj->_item_active($data->start);
        } else {
            $list['start']['active'] = false;
            $list['start']['data'] = ($itemOverride) ? pagination_item_inactive($data->start) : $pageObj->_item_inactive($data->start);
        }
        if ($data->previous->base !== null) {
            $list['previous']['active'] = true;
            $list['previous']['data'] = ($itemOverride) ? pagination_item_active($data->previous) : $pageObj->_item_active($data->previous);
        } else {
            $list['previous']['active'] = false;
            $list['previous']['data'] = ($itemOverride) ? pagination_item_inactive($data->previous) : $pageObj->_item_inactive($data->previous);
        }
        $list['pages'] = array(); //make sure it exists
        foreach ($data->pages as $i => $page){
            if ($page->base !== null) {
                $list['pages'][$i]['active'] = true;
                $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_active($page) : $pageObj->_item_active($page);
            } else {
                $list['pages'][$i]['active'] = false;
                $list['pages'][$i]['data'] = ($itemOverride) ? pagination_item_inactive($page) : $pageObj->_item_inactive($page);
            }
        }
        if ($data->next->base !== null) {
            $list['next']['active'] = true;
            $list['next']['data'] = ($itemOverride) ? pagination_item_active($data->next) : $pageObj->_item_active($data->next);
        } else {
            $list['next']['active'] = false;
            $list['next']['data'] = ($itemOverride) ? pagination_item_inactive($data->next) : $pageObj->_item_inactive($data->next);
        }
        if ($data->end->base !== null) {
            $list['end']['active'] = true;
            $list['end']['data'] = ($itemOverride) ? pagination_item_active($data->end) : $pageObj->_item_active($data->end);
        } else {
            $list['end']['active'] = false;
            $list['end']['data'] = ($itemOverride) ? pagination_item_inactive($data->end) : $pageObj->_item_inactive($data->end);
        }
		
        return ($listOverride) ? pagination_list_render($list) : $pageObj->_list_render($list);
    }
//	*/
?>
